package com.nf.health.app.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.nf.health.app.R;
import com.nf.health.app.models.SportInfo;
import com.nf.health.app.utils.ImageLoaderUtils;

import java.util.List;

public class SportInfoAdapter extends BaseAdapter {
	private Context context;
	private List<SportInfo> infos;
	public SportInfoAdapter(Context context, List<SportInfo> infos) {
		this.context = context;
		this.infos = infos;
	}
	@Override
	public int getCount() {
		if(infos != null){
			return infos.size();
		}
		return 0;
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = ViewHolder.get(parent, convertView, R.layout.item_sport_info, position);
		holder.setText(R.id.tv_name, infos.get(position).getName());
		holder.setText(R.id.tv_sport_desc, infos.get(position).getDesc());
		ImageView iv_icon = holder.getView(R.id.iv_icon);
		ImageLoaderUtils.getinstance(context).getImage(iv_icon, infos.get(position).getImg(), R.drawable.new_default_nf_icon);
		return holder.getConvertView();
	}

}
